﻿using System;

class Program
{
    static void Main(string[] args)
    {
        // 提示用户输入数组大小
        Console.Write("输入数组大小: ");
        int size = Convert.ToInt32(Console.ReadLine());

        // 创建数组
        int[] numbers = new int[size];

        // 提示用户输入数组元素
        for (int i = 0; i < size; i++)
        {
            Console.Write("输入元素 {0}: ", i + 1);
            numbers[i] = Convert.ToInt32(Console.ReadLine());
        }

        // 调用方法求解
        int max = GetMax(numbers);
        int min = GetMin(numbers);
        double average = GetAverage(numbers);
        int sum = GetSum(numbers);

        // 打印结果
        Console.WriteLine("最大值: " + max);
        Console.WriteLine("最小值: " + min);
        Console.WriteLine("平均值: " + average);
        Console.WriteLine("元素和: " + sum);
    }

    // 方法：求最大值
    static int GetMax(int[] numbers)
    {
        int max = numbers[0];
        foreach (int num in numbers)
        {
            if (num > max)
            {
                max = num;
            }
        }
        return max;
    }

    // 方法：求最小值
    static int GetMin(int[] numbers)
    {
        int min = numbers[0];
        foreach (int num in numbers)
        {
            if (num < min)
            {
                min = num;
            }
        }
        return min;
    }

    // 方法：求平均值
    static double GetAverage(int[] numbers)
    {
        double sum = 0;
        foreach (int num in numbers)
        {
            sum += num;
        }
        return sum / numbers.Length;
    }

    // 方法：求和
    static int GetSum(int[] numbers)
    {
        int sum = 0;
        foreach (int num in numbers)
        {
            sum += num;
        }
        return sum;
    }
}
